package org.come.Jpanel;



import javax.swing.*;
import java.awt.*;


public class CustomTitleBarUI1 extends JPanel {
    public CustomTitleBarUI1(JFrame frame) {
        setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
        setPreferredSize(new Dimension(5, 58));
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); // 设置鼠标样式为手型
    }


    @Override
    protected void paintComponent(Graphics g) {

//        this.setBorder(BorderFactory.createLineBorder(Color.YELLOW));
        Graphics2D g2d = (Graphics2D) g;
        Color color = new Color(113, 154, 194);
//        Color color1 = new Color(113, 154, 194);
//        GradientPaint gradient = new GradientPaint(0, 0, color, 0, getHeight() - 1, color1);
//        g2d.setPaint(gradient);
        g2d.setColor(color);
        g2d.fillRect(0, 0, getWidth(), getHeight());
        g2d.setComposite((Composite) AlphaComposite.getInstance(1, 1));
        g2d.setColor(Color.black);
        g2d.fillRect(4, -13, 1, getHeight() + 13);
    }

    public static void main(String[] args) {
        JFrame frame = new JFrame("Custom Title Bar UI Demo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 300);
//        frame.setUndecorated(true);
        CustomTitleBarUI1 customTitleBarUI = new CustomTitleBarUI1(frame);
        customTitleBarUI.setOpaque(false);
        frame.add(customTitleBarUI, BorderLayout.NORTH);

        frame.setVisible(true);
    }
}

